//
//  main.m
//  Runtime
//
//  Created by XYG on 15/12/24.
//  Copyright © 2015年 Develop  by XYG. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import <objc/message.h>
/**写一个类
 *
 */
@interface Person : NSObject
@property (nonatomic,assign)NSInteger age;
@end

@implementation Person



@end

/**
 *  <#Description#>
 */


@interface Student : Person

@end


@implementation Student



@end

int main(int argc, const char * argv[]) {
    @autoreleasepool {
//        Person *per =[[Person alloc]init];
//        per.age =100;
//        NSLog(@"%ld",per.age);
//        Person *per =((Person *(*)(id, SEL))(void *)objc_msgSend)((id)((Person *(*)(id, SEL))(void *)objc_msgSend)((id)objc_getClass("Person"), sel_registerName("alloc")), sel_registerName("init"));
//       
//        id person = ((Person *(*)(id, SEL))(void *)objc_msgSend)((id)objc_getClass("Person"), sel_registerName("alloc"));
       
//        Person *P = ((Person *(*))(id,SEL)(void *) objc_msgSend)(person,sel_registerName("init"));
       // 创建一个对象
        
        
        /**      isa        isa
         图：per －－>person－－－－>metaclass(元类)
         */
        Student *stu =[[Student alloc]init];
        
        //stu的isa指向为Student
        NSLog(@"stu:的isa的指向对象%@",object_getClass(stu));
        // 接收指向
        Class stu1 =object_getClass(stu);
        // Student的isa指向为Person
        NSLog(@"student的super指针指向%@",class_getSuperclass(stu1));
        // Student的元类指向Student
        NSLog(@"Student的元类：%@",object_getClass(stu1));
        
        // 接收指针
        Class superClass =class_getSuperclass(stu1);
        NSLog(@"-----%@",superClass);
        // Student的isa父类的指针指向
        NSLog(@"Student的isa父类指针的指向：%@",object_getClass(superClass));
        //Person的isa指针的isa指针的指向
        NSLog(@"Person的isa指针的isa指针的指向%@",object_getClass(object_getClass(superClass)));
        //Student的isa指针的isa指针指向
        NSLog(@"Student的isa指针的isa指针%@",object_getClass(object_getClass(stu1)));
        //得到的NSObject
        NSLog(@"%@",object_getClass([NSObject class]));
        //最终指向nil
        NSLog(@"%@",class_getSuperclass(class_getSuperclass(object_getClass(object_getClass(stu1)))));
        
        NSLog(@"Hello, World!");
    }
    return 0;
}
